package org.shana.shortlink.admin.controller;

import lombok.RequiredArgsConstructor;
import org.shana.shortlink.admin.common.convention.result.Result;
import org.shana.shortlink.admin.common.convention.result.Results;
import org.shana.shortlink.admin.remote.LinkGotoRemoteService;
import org.shana.shortlink.admin.remote.LinkInfoRemoteService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/short-link/admin/linkInfo")
@RequiredArgsConstructor
public class LinkInfoController {

//    private final LinkInfoRemoteService linkInfoRemoteService=new LinkInfoRemoteService() {
//    };

    LinkInfoRemoteService linkInfoRemoteService = new LinkInfoRemoteService() {
    };

    /**
     * 根据 URL 获取对应网站的标题
     */
    @GetMapping("/title")
    public Result<String> getTitleByUrl(@RequestParam("url") String url) {
        return (linkInfoRemoteService.getTitleByUrl(url));
    }
}